import { Controller, Get, Render, Request } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}
  // this.appService = new AppService();

  @Get()
  @Render('default/index')
  getHello(@Request() req) {
    // 设置session值
    req.session.userInfo = { name: '张三' };
    return { name: '张三', age: 20 };
  }

  @Get('shop')
  getShop(@Request() req): string {
    // 获取session
    console.log(req.session.userInfo);

    return req.session.userInfo;
  }

  @Get('welcome')
  getWelcome(): string {
    return this.appService.getWelcome();
  }
}
